import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    goods: [],
    slid: []
  },
  mutations: {
    getGoods(state, items) {
      state.goods = items.list
      state.slid = items.slider
    }
  },
  actions: {
    getGoods(context) {
      axios.get('/api/data.json')
        .then(res => {
          // console.log(res.data.result)
          context.commit('getGoods', res.data.result)
        }).catch(err => {
          console.error(err)
        })
    }
  },
  modules: {
  }
})
